//
//  TabBarControllerViewController.m
//  PLRLiveShow
//
//  Created by zhaoxiaoyan on 2017/8/15.
//  Copyright © 2017年 xiaoyanzhao. All rights reserved.
//

#import "TabBarControllerViewController.h"
#import "PLRLobbyViewController.h"
#import "PLRBroadcastRoomViewController.h"
#import "TheMoreViewController.h"

@interface TabBarControllerViewController () <UITabBarDelegate>

@property (nonatomic, strong) NSMutableArray *viewControllerArray;

@end

@implementation TabBarControllerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _viewControllerArray = [[NSMutableArray alloc] init];
    
    [self setupControllerForTabBarController];
    [self setupTabBar];
    
}

- (void)setupControllerForTabBarController {
    PLRLobbyViewController *lobbyVC = [[PLRLobbyViewController alloc] init];
    [self setupController:lobbyVC title:@"大厅" tabBarItemImage:nil selectedItemImage:nil];
    
    PLRBroadcastRoomViewController *broadcastVC = [[PLRBroadcastRoomViewController alloc] init];
    [self setupController:broadcastVC title:@"直播" tabBarItemImage:nil selectedItemImage:nil];
    
    TheMoreViewController *moreVC = [[TheMoreViewController alloc] init];
    [self setupController:moreVC title:@"我的" tabBarItemImage:nil selectedItemImage:nil];
    
    self.viewControllers = _viewControllerArray;
}

- (void)setupController:(UIViewController *)viewController title:(NSString *)titile tabBarItemImage:(UIImage *)image selectedItemImage:(UIImage *)selectedImage {
    
    // 如果不设置图片的这个属性，那么设置完图片之后点击，会出现系统自带的绿色，而不是图片本身的颜色
    viewController.tabBarItem.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    viewController.tabBarItem.selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
    navigationController.tabBarItem.title = titile;
    [_viewControllerArray addObject:navigationController];
}

- (void)setupTabBar {
    [self.tabBar setBarTintColor:[UIColor lightGrayColor]];
    [self.tabBar setBarStyle:UIBarStyleDefault];
    [self.tabBar setTintColor:[UIColor redColor]];
    self.tabBar.translucent = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark -- UITabBarDelegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    
}

@end
